package com.jiangduoduo.old.APIDefinition;

import com.jiangduoduo.old.common.BaseTest;
import io.restassured.response.Response;
import org.testng.annotations.Test;

import java.util.HashMap;
import java.util.Map;

import static com.jiangduoduo.old.common.BaseTest.requestByGet;
import static com.jiangduoduo.old.common.BaseTest.requestByPost;

public class APICall {

    public static void login(){
        Map<String,Object> headers = new HashMap<>();
        headers.put("Content-Type","application/x-www-form-urlencoded");
        Map<String,Object> formParams = new HashMap<>();
        formParams.put("uid","dengbaomu");
        formParams.put("upw",123456);
        formParams.put("usertype",1);
        formParams.put("login_btn","");
        formParams.put("key","login");
        String url = "http://test3.zhuangdeng.cn/crm/login.php";

        Response response = BaseTest.requestByPost(headers,formParams,url);
        //return response;
    }
    //获取商家列表
    @Test
    public static Response getTmalllist(){
        String cookie = null;
        Map<String,Object> headers = new HashMap<>();
        headers.put("Cookie","checkuser=dengbaomu%7C1%7C123.161.193.10; PHPSESSID=dalnjd2lj7coe40jr5jn1s9d22; user_level29=0; user_admin29=1; EUA_uladmin=q4b9U%2F1OOvisv41cLEwT4jcaHDqxPe5LK3N8AthVlkbno6V9qnb9xLQaJa1y4h3gviaqRkJJGIr1jG0JfO8%2BgvPif1yRAxMTew4y6m%2Fl");
        Map<String,Object> formParams = new HashMap<>();
        formParams.put("action","ajax_get_tmalllist");
        formParams.put("tmallname","测试商城");
        String url = "http://test3.zhuangdeng.cn/crm/trade_list.php";
        Response response = BaseTest.requestByGet(headers,formParams,url);
        String tmallName = response.jsonPath().get("data.2182.id");
        System.out.println(tmallName);
        return response;

    }
    //获取商家服务类目
    @Test
    public static void getClassOfTmall(){
        Map<String,Object> headers = new HashMap<>();
        //cookie来源于getTmalllist接口
        headers.put("Cookie","checkuser=dengbaomu%7C1%7C123.161.193.10; PHPSESSID=dalnjd2lj7coe40jr5jn1s9d22; user_level29=0; EUA_uladmin=q4b9U%2F1OOvisv41cLEwT4jcaHDqxPe5LK3N8AthVlkbno6V9qnb9xLQaJa1y4h3gviaqRkJJGIr1jG0JfO8%2BgvPif1yRAxMTew4y6m%2Fl; sys_msg_userid=1; sys_msg_username=dengbaomu; sys_msg_usertype=1; user_admin29=1");
        Map<String,Object> formParams = new HashMap<>();
        formParams.put("action","ajax_get_class");
        //companyid来自getTmalllist接口
        formParams.put("companyid","2705");
        String url = "http://test3.zhuangdeng.cn/crm/trade_add_new.php";
        Response response = BaseTest.requestByGet(headers,formParams,url);
        System.out.println(response);
    }
    @Test
    public static void trade_add_new(){
        Map<String,Object> headers = new HashMap<>();
        headers.put("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");

        headers.put("Cookie","checkuser=shebin%7C1%7C123.161.193.179; PHPSESSID=dalnjd2lj7coe40jr5jn1s9d22; EUA_uladmin=oNL9A6odMvyo9dxFMUMU4TEZFSPlPL9OLCN2D9UOlRLr%2B6Z9rSb%2Bl%2BEfJ%2Fwm4Eu%2Bvi38Xw8EVsdt1ltNJtPEVVJNN1%2BYDBMXc0ox%2Fm%2B1uRXmfjYlQG7EkX3MS6TerdvuvUDFm1Haeskhh%2FOK4JkSuwO%2BxO%2FGnGzCE0njv4TVyu%2BZuiTa6N1TrQKYmULegP0PP98Xy90J; sys_msg_userid=565; sys_msg_username=shebin; sys_msg_usertype=1; user_level29=0; user_admin29=565");
        Map<String,Object> formParams = new HashMap<>();
        formParams.put("key","add");
        formParams.put("pageaction","trade_list.php?companyid=&fcity3=&fcity2=&fcity1=&fmember=&linkman=&jindu=&mobile=&wangwang=&classid=&page=&address=&customname=&gettime1=&gettime2=&zt=&islocktmall=&arrived=&getproductname=&parid=&opjj=&checkDateYear=");
        formParams.put("order_id",0);
        //formParams.put("classidname","");
        formParams.put("is_celing: 0","");
        formParams.put("bxercishangmen","0");
        formParams.put("source_merchant_id","");
        formParams.put("source_merchant_name","");
        formParams.put("service_type",0);   //服务类型
        formParams.put("is_install",2);
        formParams.put("is_receive",0);
        formParams.put("ask_trade_type",11);
        formParams.put("inquiry_ids",0);
        formParams.put("tradeid",0);
        formParams.put("from_trade_id","");
        //formParams.put("memberid","0");
        formParams.put("tmallname","测试商城");
        formParams.put("companyid","2705");
        formParams.put("company_type",1);
        formParams.put("classid","1");
        formParams.put("address","郑州大学");
        formParams.put("linkman","测试");
        formParams.put("telphone","");
        formParams.put("mobile: ","15617718501");
        formParams.put("wangwang","");
        formParams.put("fcity1",97);
        formParams.put("fcity2",279);
        formParams.put("fcity3",1464);
        formParams.put("fcity4",16515);
        formParams.put("address","郑州大学");
        formParams.put("remark","");
        formParams.put("is_distance",1);
        formParams.put("distance",0);
        formParams.put("distance_value",0);
        formParams.put("distance_price_hidden",0);
        formParams.put("address_origins","");
        formParams.put("address_destination","");
        formParams.put("origin_location","");
        formParams.put("destination_location","");
        formParams.put("distance_price",0);
        formParams.put("productname","1件灯具");
        //formParams.put("subproname","");
        formParams.put("cccount",0);
        formParams.put("reason",0);
        formParams.put("content3","1件直径23cm简易吸顶灯");
        formParams.put("category[]","443");
        formParams.put("category_name[]","直径23cm简易吸顶灯");
        formParams.put("category_num[]",1);
        formParams.put("category_aprice[]",13.00);
        formParams.put("category_price[]",16.00);
        formParams.put("extra_num[]",23);
        formParams.put("package_id[]",0);
        formParams.put("orderid","");
        formParams.put("mprices","");
        formParams.put("prices",16.1);
        formParams.put("cprices","");
        formParams.put("content2","");
        formParams.put("file","");
        formParams.put("picture","");
        formParams.put("sendtime","");
        formParams.put("grouporderid","");
        formParams.put("url","");
        formParams.put("email","");
        formParams.put("companykd","");
        formParams.put("kuaidiid","");
        formParams.put("delivery_address","");
        formParams.put("file","");
        formParams.put("file","");
        formParams.put("image_h","");

        String url = "http://test3.zhuangdeng.cn/crm/trade_add_new.php";
        Response response = BaseTest.requestByPost(headers,formParams,url);
    }

    public static void main(String[] args) {
        System.out.println("佘彬");
    }
}
